<template>
    <header class="header" ref="header">
        <van-nav-bar :class="{styles:styles}" :title="title" left-text="返回" right-text="关闭" left-arrow :fixed="fixed" @click-left="back" @click-right="closeWin">
        </van-nav-bar>
    </header>
</template>
<script>
export default {
    name:'Header',
    props:{
        title:{
            type:String,
            default:''
        },
        styles:{
            type:Boolean,
            default:false
        },
        fixed:{
            type:Boolean,
            default:true
        }
    },
    mounted(){
        console.log('header:'+this.$refs.header.offsetHeight);
        this.$emit('getHeight',this.$refs.header.offsetHeight)
    },
    methods:{
        back(){
            // 后退一步记录，等同于 history.back()
            this.$router.go(-1)
        },
        closeWin(e){
            console.log(e);
            this.$router.push({path:'/deskTop'})
            // var userAgent = navigator.userAgent;
            // if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") !=-1) {
            //     window.location.href="about:blank";
            // }else if(userAgent.indexOf("Android") > -1 || userAgent.indexOf("Linux") > -1){
            //     window.opener=null;window.open("about:blank","_self","").close();
            // }else {
            //     window.opener = null;
            //     window.open("about:blank", "_self");
            //     window.close();
            // }
        }
    }
}
</script>
<style lang="less" scoped>
.header{
    width: 100%;
    height: 44px;
    line-height: 44px;
    background: #fff;
    /deep/ .van-nav-bar{height: 44px; line-height: 44px;background: #fff;}
    .van-nav-bar .van-icon{color: #616264}
    .van-nav-bar__text{color: #333;}
    /deep/ .van-nav-bar__arrow,/deep/ .van-nav-bar__title { font-size: 18px;}
    /deep/ .van-nav-bar__left,/deep/ .van-nav-bar__right {font-size: 15px;}
    .styles{
        background: #02ccbd;
        .van-nav-bar__title,
        .van-nav-bar .van-icon,
        .van-nav-bar__text,
        .van-nav-bar__arrow{color: #fff;}
    }
}
</style>